package com.jprocms.module.cms.framework.seq;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author jprocms
 */
@Service
public class TableSeqServiceImpl extends ServiceImpl<TableSeqDao, TableSeqDO> implements TableSeqService {
    @Override
    public TableSeqDO selectByTable(String tableName) {
        if (tableName == null) {
            throw new RuntimeException("bizTag 不能为空");
        }
        LambdaQueryWrapper<TableSeqDO> wrpper = new LambdaQueryWrapper<>();
        wrpper.eq(TableSeqDO::gettName, tableName);
        return super.getOne(wrpper);
    }

    @Override
    public boolean updateByTable(TableSeqDO tableSeqDO) {
        if (tableSeqDO == null || tableSeqDO.gettName() == null) {
            throw new RuntimeException("bizTag 不能为空");
        }
        LambdaQueryWrapper<TableSeqDO> wrpper = new LambdaQueryWrapper<>();
        wrpper.eq(TableSeqDO::gettName, tableSeqDO.gettName());
        return super.update(tableSeqDO, wrpper);

    }
}
